#!/bin/bash

# 创建证书目录
mkdir -p nginx/ssl
mkdir -p certs

echo "生成自签名 SSL 证书..."

# 为 Nginx 生成证书
openssl req -x509 -nodes -days 365 -newkey rsa:2048 \
    -keyout nginx/ssl/key.pem \
    -out nginx/ssl/cert.pem \
    -subj "/C=CN/ST=Beijing/L=Beijing/O=WebRTC/OU=IT Department/CN=localhost"

# 为 ASP.NET Core 生成 pfx 证书
openssl pkcs12 -export -out certs/aspnetapp.pfx \
    -inkey nginx/ssl/key.pem \
    -in nginx/ssl/cert.pem \
    -passout pass:

echo "证书生成完成！"
echo "Nginx 证书: nginx/ssl/cert.pem, nginx/ssl/key.pem"
echo "ASP.NET Core 证书: certs/aspnetapp.pfx" 